package com.cgw.game.ui;

import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.view.View;
import android.widget.TextView;

import com.cgw.game.R;
import com.cgw.game.view.WeightChoiceView;

public class WeightActivity extends AppCompatActivity {
    TextView weightValue;
    TextView heightValue;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_weight);
        Toolbar toolbar = findViewById(R.id.toolbar);
        toolbar.setTitle(getIntent().getStringExtra("title"));
        setSupportActionBar(toolbar);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);//左侧添加一个默认的返回图标
        getSupportActionBar().setHomeButtonEnabled(true); //设置返回键可用
        toolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();//返回
            }
        });
        WeightChoiceView weight = findViewById(R.id.weight);
        weightValue = findViewById(R.id.weight_value);
        weight.setListener(new WeightChoiceView.OnValueChangeListener() {
            @Override
            public void onValueChange(float value) {
                weightValue.setText("体重："+value+"Kg");
            }
        });
        heightValue = findViewById(R.id.height_value);
        WeightChoiceView height = findViewById(R.id.height);
        height.setListener(new WeightChoiceView.OnValueChangeListener() {
            @Override
            public void onValueChange(float value) {
                heightValue.setText("身高："+value+"cm");
            }
        });
    }
}
